URL Parameter Passing

Use XML Encoded Primary Key Passed via URL

Description
Record identifiers are passed from page to page via URLs in an XML-encoded format. For example, if you have a Show Table page with an Edit button, and you set that Edit button to redirect to another page, passing a record identifier on the URL. Iron Speed Designer generates a URL such as: http://localhost/MyApp3/Categories/EditCategoriesRecord.aspx?Categories=%3ckey%3e%3ccv%3e%3cc%3eCategoryID%3c%2fc%3e%3cv%3e2%3c%2fv%3e%3c%2fcv%3e%3c%2fkey%3e The URL-decoded value of the Categories parameter is: CategoryID1. This means that the primary key of the record is defined by the CategoryID column, and for this record the value is 2. For records with composite primary keys, you would see other attributes in the XML representing the names and values of the other primary key columns. You can parse and use the XML-encoded value for your own purposes using a PageLoad function in your page.
Variables
Record Control class
Select the Record control class
Table Name
Select the database table
Primary Key field
Select the primary key field
Applies to
RecordControl class
Code
 
''' 
'''Override the CreateWhereClause to retrieve the record id.
''' 
public Overrides Function CreateWhereClause() As WhereClause
    Dim wc As WhereClause = New WhereClause()

    ' Get the XML-encoded record ID from the URL parameter.
    ' This will return something like:  EmployeeID1
    '
    ' 
    '  EmployeeID
    '  1
    ' 
    '
    'cv means column value
    'c means column name
    'v means value
    Dim recId As String = Me.Page.Request.QueryString.Item("${Table Name}")
    If recId Is Nothing OrElse recId.Trim = "" Then
    
        ' Get the error message from the application resource file.
        Throw New Exception(Page.GetResourceValue("Err:UrlParamMissing", "${Application Name}").Replace("{URL}", "${Table Name}"))        
    End If
    Dim pkValue As KeyValue = KeyValue.XmlToKey(recId)
    wc.iAND(${${Table Name}ClassName}.${Primary Key field}, BaseClasses.Data.BaseFilter.ComparisonOperator.EqualsTo, pkValue.GetColumnValue(${${Table Name}ClassName}.${Primary Key field}).ToString())
    Return wc
 End Function


     

Terms of Service Privacy Statement